package org.gitman.agentplatform.agent.api;

import java.awt.Color;

public class InternalAgentInfo implements Comparable<InternalAgentInfo>, AgentInfo{
	private Integer id;
	private Integer startVertexID; 
	private Integer endVertexID;
	private Integer currentVertexID;
	private AgentState agentState;
	private Double relie;
	private Integer minObserv;
	private Integer maxObserv;
	private Integer minPredict;
	private Integer maxPredict;
	private boolean relieKnown;
	private AgentPlan agentPlan;
	private int iteration;
	private Color color;
	private String args;
	
	public Color getColor() {
		return color;
	}
	public void setColor(Color color) {
		this.color = color;
	}
	public InternalAgentInfo(){
		
	}
	public InternalAgentInfo(Integer id, Integer startVertexID,
			Integer endVertexID, Integer currentVertexID,
			AgentState agentState, Double relie, Integer minObserv,
			Integer maxObserv, Integer minPredict, Integer maxPredict,
			boolean relieKnown, AgentPlan agentPlan, int iteration,
			Color color, String args) {
		super();
		this.id = id;
		this.startVertexID = startVertexID;
		this.endVertexID = endVertexID;
		this.currentVertexID = currentVertexID;
		this.agentState = agentState;
		this.relie = relie;
		this.minObserv = minObserv;
		this.maxObserv = maxObserv;
		this.minPredict = minPredict;
		this.maxPredict = maxPredict;
		this.relieKnown = relieKnown;
		this.agentPlan = agentPlan;
		this.iteration = iteration;
		this.color = color;
		this.args = args;
	}
	public Integer getStartVertexID() {
		return startVertexID;
	}
	public void setStartVertexID(Integer startVertexID) {
		this.startVertexID = startVertexID;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getEndVertexID() {
		return endVertexID;
	}
	public void setEndVertexID(Integer endVertexID) {
		this.endVertexID = endVertexID;
	}
	public Integer getCurrentVertexID() {
		return currentVertexID;
	}
	public void setCurrentVertexID(Integer currentVertexID) {
		this.currentVertexID = currentVertexID;
	}
	public AgentState getAgentState() {
		return agentState;
	}
	public void setAgentState(AgentState agentState) {
		this.agentState = agentState;
	}
	public Double getRelie() {
		if(isReliKnown()){
			return relie;
		}
		return null;
	}
	public void setRelie(Double relie) {
		this.relie = relie;
	}
	public AgentPlan getAgentPlan() {
		return agentPlan;
	}
	public void setAgentPlan(AgentPlan agentPlan) {
		this.agentPlan = agentPlan;
	} 
	public boolean isTargetAchived(){
		return currentVertexID.equals(endVertexID);
	}
	public int  getIteration() {
		return iteration;
	}
	public void setIteration(int iteration) {
		this.iteration = iteration;
	}
	@Override
	public int compareTo(InternalAgentInfo o) {
		return id - o.getId();
	}
	@Override
	public String toString() {
		return "[" + (id == null ? "nullID" : id) + "]: ";
	}
	public String getArgs() {
		return args;
	}
	public void setArgs(String args) {
		this.args = args;
	}
	public Integer getMinObserv() {
		return minObserv;
	}
	public void setMinObserv(Integer minObserv) {
		this.minObserv = minObserv;
	}
	public Integer getMaxObserv() {
		return maxObserv;
	}
	public void setMaxObserv(Integer maxObserv) {
		this.maxObserv = maxObserv;
	}
	public Integer getMinPredict() {
		return minPredict;
	}
	public void setMinPredict(Integer minPredict) {
		this.minPredict = minPredict;
	}
	public void setMaxPredit(Integer maxPredict) {
		this.maxPredict = maxPredict;
	}
	public Integer getMaxPredict() {
		return maxPredict;
	}
	public boolean isReliKnown() {
		return relieKnown;
	}
	public void setRelieKnown(boolean relieKnown){
		this.relieKnown = relieKnown;
	}
	public void setObserv(Integer val){
		minObserv = maxObserv = val;
	}
	public void setPredict(Integer val){
		minPredict = maxPredict = val;
	}
	public void setPredict(Integer min, Integer max){
		minPredict = min;
		maxPredict = max;
	}
	public void setObserv(Integer min, Integer max){
		minObserv = min;
		maxObserv = max;
	}
	public Double getInternalRelie(){
		return relie;
	}
	public String getObservString() {
		String min = minObserv == Integer.MAX_VALUE ? "inf" : minObserv.toString();
		String max = maxObserv == Integer.MAX_VALUE ? "inf" : maxObserv.toString();
		return minObserv.equals(maxObserv) ? min : ("(" + min + ";" + max +")");
	}
	public String getPredictString() {
		String min = minPredict == Integer.MAX_VALUE ? "inf" : minPredict.toString();
		String max = maxPredict == Integer.MAX_VALUE ? "inf" : maxPredict.toString();
		return minPredict.equals(maxPredict) ? min : ("(" + min + ";" + max +")");
	}
	public String getRelieString() {
		if(isReliKnown()){
			return relie.toString();
		}else{
			return "unkown";
		}
	}
}
